﻿@model IEnumerable<Stardust.Models.ServiciosBean>


@{
    ViewBag.Title = "Index";
}

<h2>Lista de Servicios</h2>

<p>
    Lista general de los servicios del hotel
</p>

<p>
   @Html.ActionLink("Añadir", "RegistrarServicio","Servicios")<img src="../../Content/images/icons/color/plus.png" />
</p>


<div class = "widget" >

    <div class="title"><img src="../../Content/images/icons/dark/frames.png" alt="" class="titleIcon" /><h6>Servicios del hotel</h6></div>

    <table cellpadding = "0" cellspacing = "0" width = "100%" class = "sTable" >

    <thead>
        <tr>
            <td>ID</td>
            <td>Nombre</td>
            <td>Descripcion</td>
            <td></td>            
        </tr>
    </thead>

    <tbody>

    @foreach (var item in Model) {
            <tr>
                <td>  @Html.DisplayFor(modelItem => item.id)   </td>
                <td>   @Html.DisplayFor(modelItem => item.nombre)       </td>
                <td>  @Html.DisplayFor(modelItem => item.descripcion)       </td>                
                <td>
                    @Html.ActionLink("Modificar", "ModificarServicio", new { id = item.id }) <img src="../../Content/images/icons/color/pencil.png" />|
                    
                     <a  id = @item.id class = "eliminar" href=""><img src="../../Content/images/icons/color/cross.png", alt="Delete" />Borrar</a>
                    @*@Html.ActionLink("Eliminar", "EliminarServicio", new { id = item.id }) <img src="../../Content/images/icons/color/cross.png" />   *@                 
                
                </td>
            </tr>
    }
    
    <div id="dialogEliminar" title="Desea Eliminar el Servicio?">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
    El Servicio que UD. Elimine ya no podra ser recuperado</p>
    </div>

    </tbody>

    </table>
</div>




<script type = "text/javascript">
    var idEliminar = 0;
    $(".eliminar").click(function () {
        //Jp++ GPL version xD
        $('#dialogEliminar').dialog('open');
        idEliminar = $(this).attr("id");
        return false;
    });

    $('#dialogEliminar').dialog({
        autoOpen: false,
        resizable: false,
        draggable: false,
        width: 300,
        modal: true,
        title: "!Confirmar Eliminacion de Servicio",
        position: "center",
        buttons: {
            "Aceptar": function () {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    url: "Servicios/Delete/" + idEliminar,
                    success: function (data) {
                        //oTable.fnDraw(false);
                        if (data.me == "") {
                            $(this).dialog("close");
                            location.reload();
                        }
                    }
                });

            },
            "Cancelar": function () {
                $(this).dialog("close");
                return false;
            }
        }
    });

</script>